﻿package mortal.game.view.copy.ZZXYBattle
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class ZZXYBattleRoom extends GSprite
    {
        private var _bg:GImageBitmap;
        private var _number:BitmapNumberText;
        private var _txt:GTextFiled;
        private var _selected:Boolean = false;
        private var _enabled:Boolean = true;
        public var roomId:int;
        private var _callback:Function;

        public function ZZXYBattleRoom()
        {
            return;
        }// end function

        public function set clickCallback(param1:Function) : void
        {
            this._callback = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this._bg = UIFactory.gImageBitmap(null, 0, 0, this);
            LoaderHelp.setBitmapdata("ZZXYBattleRoomBg.swf", this._bg);
            this._number = UIFactory.bitmapNumberText(62, 3, "ArenaNum.png", 43.7, 62, -1, this, 9);
            this._number.align = BitmapNumberText.Mid;
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.color = 12707050;
            _loc_1.align = TextFormatAlign.CENTER;
            _loc_1.size = 15;
            _loc_1.bold = true;
            this._txt = UIFactory.gTextField("0/10", 0, 62, 129, 26, this, _loc_1);
            this.configEventListener(MouseEvent.CLICK, this.clickMeHandler);
            return;
        }// end function

        public function clickMeHandler(event:MouseEvent) : void
        {
            if (this._callback != null)
            {
                this._callback.apply(null, [this]);
            }
            return;
        }// end function

        public function get isFull() : Boolean
        {
            return !this.mouseEnabled;
        }// end function

        public function updateRoomNumber(param1:int) : void
        {
            this.roomId = param1;
            this._number.text = this.roomId.toString();
            return;
        }// end function

        public function updatePlayerNum(param1:int, param2:int = 10) : void
        {
            this._txt.text = param1 + "/" + param2;
            var _loc_3:* = param1 >= param2;
            var _loc_4:* = ZZXYBattleController.myRoomId;
            var _loc_5:* = _loc_4 <= 0 || _loc_4 == this.roomId;
            if (_loc_5)
            {
                this.setEnable(true);
            }
            else
            {
                this.setEnable(false);
            }
            if (_loc_5 && _loc_4 > 0)
            {
                this.clickMeHandler(null);
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (this.parent != null)
            {
                this.parent.removeChild(this);
            }
            this._bg.dispose();
            this._bg = null;
            this._number.dispose();
            this._number = null;
            this._txt.dispose();
            this._txt = null;
            this._selected = false;
            this._enabled = true;
            return;
        }// end function

        public function setEnable(param1:Boolean) : void
        {
            this._enabled = param1;
            this.mouseChildren = param1;
            this.mouseEnabled = param1;
            this.updateFilter();
            return;
        }// end function

        public function selecte(param1:Boolean) : void
        {
            this._selected = param1;
            this.updateFilter();
            return;
        }// end function

        private function updateFilter() : void
        {
            if (this._enabled)
            {
                if (this._selected)
                {
                    this.filters = [FilterConst.guideFilter];
                }
                else
                {
                    this.filters = [];
                }
            }
            else
            {
                this.filters = [FilterConst.colorFilter];
            }
            return;
        }// end function

    }
}
